package logic

import (
	"baidutieba/models/mysql"
	"baidutieba/tiebarpc/internal/svc"
	"baidutieba/tiebarpc/tiebarpc"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type ClassAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewClassAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClassAddLogic {
	return &ClassAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ClassAddLogic) ClassAdd(in *tiebarpc.ClassAddRequest) (*tiebarpc.ClassAddResponse, error) {
	// todo: add your logic here and delete this line
	ba := mysql.Class{
		UserId:  in.UserId,
		TieBaId: in.TieBaId,
		Class:   in.Class,
	}

	mysql.DB.Create(&ba)
	return &tiebarpc.ClassAddResponse{
		Id: int64(ba.ID),
	}, nil
}
